<%@ page language="java"
	import="com.gy.sams.dao.*,com.gy.sams.dao.impl.*,com.gy.sams.entity.*"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	int flag=0;
	request.setCharacterEncoding("utf-8");
	String id=request.getParameter("aId");
	String name=request.getParameter("aName");
	String grade=request.getParameter("aSscore");
	//判断用户是否存在
	User user=new User();
	user.setUname(name);
	user.setUpass(name);
	user.setRole(0+"");
	IUserDao userDao=new UserDaoImpl();
	user=userDao.findUser(user);
	if(user!=null){
		out.print("<script type='text/javascript'>alert('用户已存在！');location.replace('../tableScore.jsp')</script>");
	}else{
		IScoreDao scoreDao=new ScoreDaoImpl();
		flag=scoreDao.addScore(name,grade);
		if(flag!=0){
			out.print("<script type='text/javascript'>alert('成功添加新学生，增加学生成绩成功');location.replace('../tableScore.jsp')</script>");
		}
		else{
			out.print("<script type='text/javascript'>alert('增加失败');location.replace('../tableScore.jsp')</script>");
		}
	}
	
	
%>